#include "swpstartpointgraphicitem.h"

#include "graphicitemcommon.h"

using namespace core;
using namespace gui;
using namespace swp;

SwpStartPointGraphicItem::SwpStartPointGraphicItem(QGraphicsItem* parent) :
    AbstractEllipseGraphicItem(parent)
{
    QRectF rect(0.5, 0.5, 50.5, 50.5);

    setRectF(rect);

    setFlags(flags() | QGraphicsItem::ItemIsMovable |
        QGraphicsItem::ItemIsSelectable);

    setPen(QPen(Qt::transparent, 0));
    setBrush(QBrush(Qt::black, Qt::SolidPattern));
}

SwpStartPointGraphicItem::~SwpStartPointGraphicItem()
{

}

int SwpStartPointGraphicItem::paletteType() const
{
    return Whole;
}

bool SwpStartPointGraphicItem::supportsConnection(
    const core::ConnectionData& connection) const
{
    bool ret = connection.From == 0 &&
        connection.ConnectionId == CONNECTION_ACTIVITY &&
        connections().size() == 0;

    return ret;
}

int SwpStartPointGraphicItem::type() const
{
    return SWP_START_POINT_ITEM;
}

QString SwpStartPointGraphicItem::name() const
{
    return QObject::tr("Start point");
}

IEditorItem* SwpStartPointGraphicItem::copy() const
{
    return new SwpStartPointGraphicItem(0);
}

QList<core::Property> SwpStartPointGraphicItem::properties() const
{
    QList<Property> ret;

    return ret;
}

QVariant SwpStartPointGraphicItem::propertyValue(
        const QString& propertyName) const
{
    QVariant ret;

    return ret;
}

void SwpStartPointGraphicItem::propertyChanged(const QString& property,
    const QVariant& newValue, bool silent)
{
    // do nothing
}

QVariantList SwpStartPointGraphicItem::optionList(
    const QString& propertyName) const
{
    QVariantList ret;

    return ret;
}

QVariantList SwpStartPointGraphicItem::autocomplete(
    const QString& propertyName) const
{
    QVariantList ret;

    return ret;
}

QList<QPointF> SwpStartPointGraphicItem::scalePoints() const
{
    QList<QPointF> ret;

    ret << QPointF(0.0, 0.0) << QPointF(50, 0)
        << QPointF(50, 50) << QPointF(0, 50);

    return ret;
}

QList<QPointF> SwpStartPointGraphicItem::connectPoints() const
{
    QList<QPointF> ret;

    ret << QPointF(25, 0.0) << QPointF(50, 25)
        << QPointF(25, 50) << QPointF(0, 25);

    return ret;
}

QList<QPointF> SwpStartPointGraphicItem::selfConnectAnchorPoints() const
{
    QList<QPointF> ret;

    ret << QPointF(25, -20.0) << QPointF(70, 25)
        << QPointF(25, 70) << QPointF(-20, 25);

    return ret;
}
